import React, { Component } from 'react';
import { Route, Switch, Redirect } from 'react-router-dom';

import list from '../config/list.js';
import AsyncComponent from '../utils/AsyncLoad/AsyncComponent.jsx';
const ErrorPage = AsyncComponent(() => import('../layouts/Error.jsx'));
export default class Routers extends Component {
    render() {
        return (
            <div className="routerRoot">
                <div className="routerList">
                    <Switch>
                        {list.map((item, index) => {
                            return (
                                <Route component={item.component} exact={item.exact} key={index} path={item.url}></Route>
                            )
                        })}
                        <Route component={ErrorPage} exact path="/ErrorPage"></Route>
                        <Redirect to="/ErrorPage"></Redirect>
                    </Switch>
                </div>
            </div>
        )
    }
}